package homework3;

import ilog.concert.IloException;
import ilog.concert.IloNumVar;
import ilog.cplex.IloCplex;

public class cuttingplane {
    public void hh(){
        try {
            IloCplex cplex = new IloCplex(); // creat a model
            double[] lb = {0.0, 0.0};
            double[] ub = {Double.MAX_VALUE,Double.MAX_VALUE};
            IloNumVar[] V = cplex.numVarArray(2, lb, ub);
            double[] objvals = {6,8};
            cplex.addMinimize(cplex.scalProd(V, objvals));
            double[] coeff1 = {3,1};
            double[] coeff2 = {1,2};
            double[] coeff3 = {10,5};
            double[] coeff4 = {5,5};
            cplex.addGe(cplex.scalProd(V, coeff1), 4);
            cplex.addGe(cplex.scalProd(V, coeff2), 4);
            //cplex.addGe(cplex.scalProd(V,coeff3),20);
            cplex.addGe(cplex.scalProd(V,coeff4),15);
            if (cplex.solve()) {
                cplex.output().println("Solution status = " + cplex.getStatus());
                cplex.output().println("Solution value = " + cplex.getObjValue());
                double[] val = cplex.getValues(V);
                for (int j = 0; j < val.length; j++)
                    cplex.output().println("variable_" + (j+1) + " = " + val[j]);
            }
            cplex.end();
        } catch (
        IloException e) {
            System.err.println("Concert exception caught: " + e);
        }
    }

//    public static void main(String[] args) {
//        cuttingplane cc = new cuttingplane();
//        cc.hh();
//    }
}
